<template>
  <div class="dv">
    <p><input type="text" placeholder="邮箱" v-model="data.email" /></p>
    <p><input type="text" placeholder="密码" v-model="data.password" /></p>
    <button @click="logins">登录</button>
  </div>
</template>

<script lang="ts" setup>
import { ref, reactive, toRefs } from "vue";
import { useStore } from "vuex";
import { useRouter, useRoute } from "vue-router";
import { getLogin } from "../utils/api";
const router = useRouter();
const store = useStore();
const data = reactive({
  email: "2110410005@qq.com",
  password: "liu129499",
});
// 登录
const logins = () => {
  getLogin(data).then((res) => {
    console.log(res);
    store.commit("token", res.data.data.token);
    router.push("/index");
  });
};
</script>

<style lang="scss">
.dv {
  background: pink;
  width: 500px;
  height: 300px;
  margin: auto;
  text-align: center;
  input {
    margin: 30px;
    height: 35px;
  }
}
</style>
